#include "widget.h"
#include "ui_widget.h"
#include<QIcon>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->pushButton_dog->setIcon(QIcon(":/keji.png"));
    ui->pushButton_dog->setIconSize(QSize(100,100));
    ui->pushButton_up->setIcon(QIcon(":/up.png"));
    ui->pushButton_up->setIconSize(QSize(101,91));
    ui->pushButton_down->setIcon(QIcon(":/down.png"));
    ui->pushButton_down->setIconSize(QSize(101,91));
    ui->pushButton_left->setIcon(QIcon(":/left.png"));
    ui->pushButton_left->setIconSize(QSize(101,91));
    ui->pushButton_right->setIcon(QIcon(":/right.png"));
    ui->pushButton_right->setIconSize(QSize(101,91));

    ui->pushButton_up->setShortcut(QKeySequence("w"));
    ui->pushButton_down->setShortcut(QKeySequence("s"));
    ui->pushButton_right->setShortcut(QKeySequence("d"));
    ui->pushButton_left->setShortcut(QKeySequence("a"));


}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_up_clicked()
{
    const QRect& rect=ui->pushButton_dog->geometry();
    ui->pushButton_dog->setGeometry(rect.x(),rect.y()-10,rect.width(),rect.height());
}

void Widget::on_pushButton_left_clicked()
{
    QRect rect=ui->pushButton_dog->geometry();
    ui->pushButton_dog->setGeometry(rect.x()-10,rect.y(),rect.width(),rect.height());
}

void Widget::on_pushButton_right_clicked()
{
    QRect rect=ui->pushButton_dog->geometry();
    ui->pushButton_dog->setGeometry(rect.x()+10,rect.y(),rect.width(),rect.height());
}

void Widget::on_pushButton_down_clicked()
{
    QRect rect=ui->pushButton_dog->geometry();
    ui->pushButton_dog->setGeometry(rect.x(),rect.y()+10,rect.width(),rect.height());
}
